﻿using System.Windows;
using ProjectBilling.Business.MVC.NonLeaking;
using ProjectBilling.DataAccess;

namespace ProjectBilling.UI.MVC.NonLeaking
{
    public interface IProjectsController
    {
        void ShowProjectsView(Window owner);
        void Update(Project project);
    }

    public class ProjectsController : IProjectsController
    {
        private readonly IProjectsModel model;

        public ProjectsController(IProjectsModel projectModel)
        {
            model = projectModel;
        }

        public void ShowProjectsView(Window owner)
        {
            ProjectsView view 
                = new ProjectsView(this, model);
            view.Owner = owner;
            view.Show();
        }

        public void Update(Project project)
        {
            model.UpdateProject(project);
        }
    }
}
